package cn.chuanw.db.service;

import cn.chuanw.db.dao.WSummaryMapper;
import com.github.pagehelper.PageHelper;
import cn.chuanw.db.domain.WSummary;
import cn.chuanw.db.domain.WSummaryExample;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: wangkun
 * @Date:  20-02-09 下午 4:02
 * @Description: 结算类
 **/
@Service
public class SummaryService {
    @Resource
    private WSummaryMapper wSummaryMapper;

    public List<WSummary> querySelective(String userId, Integer page, Integer size) {
        WSummaryExample wSummaryExample = new WSummaryExample();
        WSummaryExample.Criteria criteria = wSummaryExample.createCriteria();
        if (!StringUtils.isEmpty(userId)) {
            criteria.andUserIdEqualTo(userId);
        }
        PageHelper.startPage(page, size);
        return wSummaryMapper.selectByExample(wSummaryExample);
    }

    public void create(WSummary wSummary) {
        wSummaryMapper.insertSelective(wSummary);
    }

    public int updateById(WSummary wSummary) {
        return wSummaryMapper.updateByPrimaryKeySelective(wSummary);
    }

}
